home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
lib
/
mntlib44.zoo
/
mntlib
/
kill.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-22
|
1KB
|
62 lines
/* kill() for MiNT */
#include <stdlib.h>
#include <errno.h>
#include <osbind.h>
#include <signal.h>
#include <unistd.h>
#include <mintbind.h>
extern int __mint;
/* vector of signal handlers (for TOS) */
extern __Sigfunc _sig_handler[]; /* in signal.c */
/* vector giving which signals are currently blocked from delivery (for TOS) */
extern long _sigmask; /* in signal.c */
/* which signals are pending? */
extern long _sigpending;
int
kill(pid, sig)
int pid, sig;
{
long r;
__Sigfunc hndle;
if (__mint) {
r = Pkill(pid, sig);
if (r < 0) {
errno = (int) -r;
return -1;
}
} else {
if (sig < 0 || sig >= NSIG || (pid && pid != getpid())) {
errno = ERANGE;
return -1;
}
hndle = _sig_handler[sig];
if (hndle == SIG_IGN)
return 0;
/* check here for masked signals */
else if (sig != SIGKILL && (_sigmask & (1L << sig)))
_sigpending |= (1L << sig);
else {
_sigpending &= ~(1L << sig);
if (hndle == SIG_DFL) {
switch (sig) {
case SIGCONT:
case SIGCHLD:
return 0;
default:
exit(sig << 8);
}
} else {
(*hndle)(sig);
}
}
}
return 0;
}